﻿using CPPEI.ETL.DataServiceInterface;
using CPPEI.WebApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ENT = CPPEI.ETL.Domain.Entities;
using MOD = CPPEI.ETL.Domain.Models;
using SER = CPPEI.ETL.Domain.Services;

namespace CPPEI.ETL.WebApi
{
    /// <summary>
    /// 将事件模式执行的任务注册到EBS
    /// </summary>
    [CPPEI.WebApi.AuthPostAction("TASK", "Register2EBS", "1.0")]
    public class Register2EBSAction : BaseAction<Register2EBSParams, CPPEI.ETL.Domain.Data.Register2EBSResult>
    {
        protected override ActionResult<CPPEI.ETL.Domain.Data.Register2EBSResult> OnExecute(ActionContext context, 
            SysParameters sysParameters,
            Register2EBSParams opParams)
        {
            ServiceResult<CPPEI.ETL.Domain.Data.Register2EBSResult> result = SER.EBSService.RegisterAllEventTask();
            if(result.IsSuccess)
            {
                return new ActionResult<CPPEI.ETL.Domain.Data.Register2EBSResult>(result.Data);
            }
            else
            {
                return new ActionResult<CPPEI.ETL.Domain.Data.Register2EBSResult>(result.IsSuccess, result.ErrorCode, result.Message, null);
            }
        }
    }

    public class Register2EBSParams
    {
    }
}
